package com.hxy.service.Impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.hxy.dao.AddressbookMapper;
import com.hxy.dao.StuffinfoMapper;
import com.hxy.pojo.Addressbook;
import com.hxy.pojo.model.GetUtilPagerequest;
import com.hxy.pojo.vo.AddressBookVo;
import com.hxy.service.AddBookService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class AddBookServiceImpl implements AddBookService {
    @Autowired
    private AddressbookMapper addressbookMapper;
    @Autowired
    private StuffinfoMapper stuffinfoMapper;

    @Override
    public int deleteByPrimaryKey(Integer id) {
        return addressbookMapper.deleteByPrimaryKey(id);
    }

    @Override
    public int insert(Addressbook record) {
      return   addressbookMapper.insert(record);
    }

    @Override
    public Addressbook selectByPrimaryKey(Integer id) {
        return addressbookMapper.selectByPrimaryKey(id);
    }

    @Override
    public List<Addressbook> selectAll() {
        return null;
    }

    @Override
    public int updateByPrimaryKey(Addressbook record) {
        return addressbookMapper.updateByPrimaryKey(record);
    }

    @Override
    public PageInfo<AddressBookVo> selectPageInfo(Integer page, int limit, String stuffName, String sex, String phone, String branch) {
        PageHelper.startPage(page, limit);
        GetUtilPagerequest getUtilPagerequest = new GetUtilPagerequest(sex, stuffName, phone, branch);
        System.out.println("是答的5as"+getUtilPagerequest);

        List<AddressBookVo> addressBookVos=addressbookMapper.selectPageInfo(getUtilPagerequest);
        PageInfo<AddressBookVo> pageInfo=new PageInfo<>(addressBookVos);
        return pageInfo;
    }
}
